package asdf.trial;

import java.net.*;
import java.util.Enumeration;

/**
 * Created by chengwenlee on 12/14/15.
 */
public class LocalIP
{

    public static void main(String[] args) throws SocketException
    {
        Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
        while ( e.hasMoreElements() ) {
            NetworkInterface ni = e.nextElement();
            for ( InterfaceAddress ia : ni.getInterfaceAddresses() ) {
                InetAddress address = ia.getAddress();
                if ( address instanceof Inet6Address ||
                     address.isAnyLocalAddress() ||
                     address.isLoopbackAddress() ) {
                    continue;
                }
                System.out.println(address);
                System.out.println("------------------------");
            }
            System.out.println("==========================");
        }
    }

}
